//#include "GameObject.h"
#include <iostream>
#ifdef __cplusplus
    #include <cstdlib>
#else
    #include <stdlib.h>
#endif
#ifdef __APPLE__
#include <SDL/SDL.h>
#else
#include <SDL.h>
#endif


using namespace std;

/*GameObject::GameObject()
{
    protected:

        int x, y, width, height, right_bound, bottom_bound, velocity_x, velocity_y;
        SDL_Surface* image;*/


//    GameObject::GameObject(int _x, int _y, int w, int h, int rb, int bb, int vx, int vy, SDL_Surface* img){

//    }

class GameObject
{

    public:
        int x, y, width, height, right_bound, bottom_bound, velocity_x, velocity_y, health;
        SDL_Surface* image;

        void update(int _x, int _y, int w, int h, int rb, int bb, int vx, int vy, SDL_Surface* img){
            x = _x;
            y = _y;
            width = w;
            height = h;
            right_bound = rb;
            bottom_bound = bb;
            velocity_x = vx;
            velocity_y = vy;
            image = img;
        }

        void set_health(){
            health = 100;
        }

        void load_image(const char* filename){
            image = SDL_LoadBMP(filename);
        }

        SDL_Surface* return_image(){
            return image;
        }

        void set_velocity_x(int val){
            velocity_x = val;
        }

        void set_velocity_y(int val){
            velocity_y = val;
        }

        void move(){
            x +=velocity_x;
            y +=velocity_y;
        }

        bool out_of_bounds(){
            if(x < 0 || x > right_bound){
                return true;
            }
            if(y < 0 || y > bottom_bound){
                return true;
            }
            return false;
        }

};

class Tank : public GameObject {
 public:
        bool intersects(){
          return true;
      }
        void fix_health(){

            if (health < 0){
                health = 0;
            }
        }



};


class Bullet : public GameObject {
    public:

        bool intersects(Tank a, int bullX, int bullY){
            if ((bullX < a.x + a.width + 75) && (bullX > a.x-30) && (bullY > a.y-23) && (bullY < a.y + a.height+7) && (a.health > 0)){
                a.health -= 20;
                destroy();
                return true;
            }
            return false;
        }

        void destroy(){
            load_image("trollface.bmp");
            health = 0;
        }



};





/*
        void GameObject::load_image(const char* filename){
            image = SDL_LoadBMP(filename);
        }

        SDL_Surface* GameObject::return_image(){
            return image;
        }

        void GameObject::set_velocity_x(int val){
            velocity_x = val;
        }

        void GameObject::set_velocity_y(int val){
            velocity_y = val;
        }

        void GameObject::move(){
            x +=velocity_x;
            y +=velocity_y;
        }

        void GameObject::accelerate(){
            if(x < 0 || x > right_bound){
                velocity_x = 0;
            }
            if(y < 0 || y > bottom_bound){
                velocity_y = 0;
            }
        }
        */


/*GameObject::~GameObject()
{
    //dtor
}*/
/*
int main(){
return 0;
}*/
